package com.chenl.interview.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @GetMapping("/test")
    @SentinelResource(value = "test1", blockHandler = "handleFlowQpsException")
    public String test() {
        return "Hello Sentinel!";
    }

    // 流控异常处理
    public String handleFlowQpsException(BlockException e) {
        return "Request blocked by Sentinel: " + e.getClass().getSimpleName();
    }
}
